package net.aiform.template.pojo;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import net.aiform.pojo.Identity;
@Entity
@Table(name = "af_option")
public class Option extends Identity  implements Serializable {
	private static final long serialVersionUID = 4331954858683348318L;
	private boolean random;
	private boolean custom;
	@OneToMany(mappedBy = "option", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Set<Item> items;
	@ManyToOne(cascade = CascadeType.REFRESH, optional = false)
	@JoinColumn(name = "field", referencedColumnName = "id")
	private Field field;

	public Set<Item> getItems() {
		return items;
	}

	public boolean isCustom() {
		return custom;
	}

	public boolean isRandom() {
		return random;
	}

	public void setCustom(boolean custom) {
		this.custom = custom;
	}

	public void setItems(Set<Item> items) {
		this.items = items;
	}

	public void setRandom(boolean random) {
		this.random = random;
	}

	@Override
	public String toString() {
		return "Option [custom=" + custom + ", items=" + items + ", random=" + random + ", code=" + code + ", createTime=" + createTime
				+ ", expireTime=" + expireTime + ", id=" + id + ", name=" + name + "]";
	}

	public Field getField() {
		return field;
	}

	public void setField(Field field) {
		this.field = field;
	}
}
